<template>
	<view>
		<Header title="客资管理" :backshow="true"></Header>
		<view class="toubu">
			<!-- 搜索开始 -->
			<view class="content_content" style="width: calc(100% - 12rpx);">
				<view class="index_header">
					<view class="">
						<view>
							<image src="/static/image/index/sousuo.png" @click="onKeyInput"></image>
							<input class="search_neirong" v-model="search" :disabled="shows" type="search" @confirm="onKeyInput"
								placeholder="搜索客户" placeholder-class="index_placeholder">
						</view>
					</view>
					<view class="img_sx" @click="shaixuans()">
						<image src="/static/image/index/shaixuan.png"></image>
					</view>
				</view>
			</view>
			<!-- 搜索结束 -->
			<!-- 导航栏 -->
			<view class="content_content nav_list">
				<view class="_list" @click="dianji(index,item.name)" v-for="(item,index) in nav" :key="index">
					<view :class="{hunsha_sy:index == di_index}">{{item.name}}</view>
					<image src="/static/image/index/xuanzhong.png" v-if="index == di_index" mode=""></image>
				</view>
			</view>
			<!-- 列表 -->
			<!-- <view class="aaaaaaaaaaaaaa" @click="popupWindow">
				点击订阅
			</view> -->
			<view class="content_content_con yinying"
				@click="publics.navigateTo('/view/index/xiangqing_kz?id='+item.id+'&typeid='+typeid)" v-for="item in xinxi">
				<view class="zhuangtai">
					<view>客资ID:{{item.id}}
						<image src="/static/image/me/fuzhi.png" @click.stop="publics.fuzhi(item.id)" class="fuzhi">
						</image>
					</view>
					<view :class="{dailingqu:item.typeid == 0,daizhuanrang:item.typeid == 4,yifangqi:item.typeid == 5,tuihui:item.typeid == 11}">{{item.typename}}</view>
				</view>
				<view class="xinxi">
					<view class="xingming">姓名：{{item.kzname}}</view>
					<view>客户类型：{{item.servertype}}</view>
					<view class="dianhua">联系电话：{{item.tel}}</view>
					<view class="wechart">微信号：{{item.wechat}}</view>
					<view>预计婚期：{{item.wedding}}</view>
					<view class="chengshi">拍摄城市：{{publics.s_dizhi()}}</view>
					<view class="zhuanrang" v-if="item.upusername!==''">转让人：{{item.upusername}}</view>
					<!-- <view class="chengshi">拍摄城市：
	 <view  v-for="ite in item.wantcity">{{ite}}</view>
	 </view> -->
				</view>
			</view>


			<view class="grace-loading" v-if="xiala==0 && xinxi.length > 15">上拉加载更多~</view>
			<view class="grace-loading" v-if="xiala==1 && zanwu != 1">没有更多数据啦~</view>
			<zanwushuju v-if="xinxi.length==0 && zanwu==1"></zanwushuju>
		</view>

		<requestLoading></requestLoading>

		<shaixuan :show="shows" @shaixuan="shaixuan" margin="calc(var(--status-bar-height) + 228rpx)"></shaixuan>

	</view>
</template>

<script>
	import shaixuan from "@/components/shaixuan.vue"
	export default {
		components: {
			shaixuan
		},
		data() {
			return {
				zanwu: 1,
				tishi: 1, //展示加载动画
				pagenum: 1,
				xiala: 999,
				index: '',
				search: '', //搜索
				di_index: 0,
				language: '',
				nav: [{
					name: "公海",
					typeid: "0",
				}, {
					name: "待领取",
					typeid: "1",
				}, {
					name: "待转让",
					typeid: "2"
				}, {
					name: "已放弃",
					typeid: "3"
				},{
					name: "客资退回",
					typeid: "4"
				}],
				shows: false, //筛选弹框是否展示
				// tishi:2,
				sift: '',
				xinxi: [],
				sxtyp: "",
				typeid:''
			}
		},
		onLoad: function() {

		},
		onShow() {
			// if(this.tishi !=2){
			this.liebiao()
			// }
		},
		onPullDownRefresh() {
			this.tishi = 2;
			this.xiala = -1;
			this.pagenum = 1;
			this.liebiao()
			console.log("触发下拉刷新")
		},
		onReachBottom() {
			console.log("上拉加载")
			if (this.xiala === 0) {
				this.pagenum++;
				this.tishi = 1;
				// this.sift;
				this.liebiao()
			}
		},
		computed: {
		},
		methods: {
			// popupWindow() {
			// 	uni.showModal({
			// 		title: '温馨提示',
			// 		content: '工单系统将即使为您更新工单状态',
			// 		confirmText: "同意",
			// 		cancelText: "拒绝",
			// 		success: function(res) {
			// 			if (res.confirm) {
							
			// 				uni.requestSubscribeMessage({
			// 					tmplIds: ['A7dwzHqZmq0IoHuaFjL3HLT59xZuKzr9SQfNf5Ceir8'],
			// 					complete: (res) => {
			// 						uni.showToast({
			// 							title: '订阅成功',
			// 							icon: "none"
			// 						});
			// 					}
			// 				})
			// 			} else if (res.cancel) {
			// 				///显示第二个弹说明一下
			// 				wx.showModal({
			// 					title: '温馨提示',
			// 					content: '拒绝后您将无法收到中奖消息',
			// 					confirmText: "知道了",
			// 					showCancel: false,
			// 					success: function(res) {
			
			
			// 					}
			// 				});
			// 			}
			// 		}
			// 	})
			// },
			liebiao() {
				var that = this;
				this.configure.ajax({
					url: "kz/allkz",
					tishi: that.tishi,
					data: {
						typeid: that.di_index,
						sift: that.sift,
						pagenum: that.pagenum,
						search:that.search
					},
					method: 'POST',
					success: function(res) {
						console.log('pagenum')
						console.log(that.pagenum)
						if (res.data.resource == null || res.data.resource.length == 0) {
							if (that.pagenum == 1) {
								that.xinxi = []
							}
							that.xiala = 1;
							return;
						} else {
							that.xiala = 0;
							if (that.tishi === 2) {
								that.xinxi = res.data.resource
							} else {
								if (that.pagenum == 1) {
									that.xinxi = res.data.resource
								} else {
									that.xinxi = that.xinxi.concat(res.data.resource)
								}
							}

						}
						that.tishi = '1111'
						that.$forceUpdate();
					}
				})
			},
			dianji(index, name) {
				this.pagenum = 1;
				this.tishi = 1;
				this.di_index = index;
				this.liebiao()
			},
			shaixuans() {
				this.shows = !this.shows;
			},
			shaixuan(e) {
				var that = this;

				if (e.states == 2) {
					that.pagenum = 1;
					that.configure.ajax({
						url: 'kz/allkz',
						tishi: that.tishi,
						data: {
							typeid: that.di_index,
							sift: e.sxtype,
							pagenum: that.pagenum,
							search:that.search
						},
						method: 'POST',
						success: function(res) {
							that.xinxi = res.data.resource

							that.tishi = '1111'
						}

					})
				}
				this.shows = false;
			},
			onKeyInput: function() {
				var patt1 = new RegExp(/\s+/g); //正则验证空格
				// if (this.search == '') {
				// 	uni.showToast({
				// 		title: '请输入关键字',
				// 		icon: "none"
				// 	});
				// 	return false;
				// } else if (patt1.test(this.search)) {
				// 	uni.showToast({
				// 		title: '请输入关键字',
				// 		icon: "none"
				// 	});
				// 	return false;
				// }
				this.liebiao()
				// this.diyici = -1;
				console.log("1111111")
			},


		}

	}
</script>

<style lang="scss" scoped>
	.aaaaaaaaaaaaaa{
		font-size: 30rpx;
		font-weight: bold;
		color: red;
	}
	.dailingqu{
		color: #00bc12 !important;
	}
	.daizhuanrang{
		color: #f47983 !important;
	}
	.yifangqi{
		color: #F1B619 !important;
	}
	.tuihui{
		color: #EC5555 !important;
	}
	.fuzhi {
		width: 24rpx;
		height: 24rpx;
		margin-left: 18rpx;
	}

	.grace-loading {
		text-align: center;
		color: $qianhui_ziti;
		font-size: 30rpx;
		margin-top: 40rpx;
		margin-bottom: 40rpx;
	}

	.xingming {
		word-break: break-all;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		overflow: hidden;
		width: 208rpx;
	}

	.wechart {
		// margin-left: 66rpx;
		word-break: break-all;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		overflow: hidden;
		width: 234rpx;
	}

	.dianhua {
		width: 300rpx;
	}

	.chengshi {
		width: 640rpx;

	}

	// .wechart{
	// 	  width: 236rpx;
	// 	  word-break: break-all;
	// 	      display: -webkit-box;
	// 	      -webkit-line-clamp: 1;
	// 	      -webkit-box-orient: vertical;
	// 	      overflow: hidden;
	// 	      margin-left: 27px !important;
	// 	      text-align: left;


	//   }

	.img_sx {
		box-shadow: $shadow_zhuse;
		width: 35rpx;
		height: 35rpx;

		image {
			width: 35rpx;
			height: 35rpx;
		}
	}

	.hunsha_sy {
		font-weight: bold;
		color: $heise_ziti !important;
		font-size: 34rpx;
	}

	.nav_list {
		margin-top: 140rpx;
		display: flex;
	}

	._list {
		position: relative;

		view {
			font-size: 28rpx;
			margin-right: 54rpx;
			padding-bottom: 30rpx;
			color: $qianhui_ziti;
		}

		image {
			width: 30rpx;
			height: 8rpx;
			position: absolute;
			top: 46rpx;
			left: 12rpx;
		}
	}

	.zhuangtai {
		font-size: 26rpx;
		color: $heise_ziti;
		display: flex;
		justify-content: space-between;
		border-bottom: 2rpx solid var(--qianhui_eee);
		padding: 30rpx 0rpx 24rpx 0rpx;
	}

	.zhuangtai view:last-child {
		color: $chengse_color;
	}

	.yinying {
		box-shadow: $shadow;
	}

	.xinxi {
		font-size: 26rpx;
		color: $qianhuione_ziti;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		margin-bottom: 30rpx;

		view {
			padding: 24rpx 0 0 0;
		}
	}

	// .xinxi view:nth-child(2){
	//  margin-left: 154rpx;
	// }
</style>
